package cn.lger.icollege.controller;

import lombok.extern.apachecommons.CommonsLog;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;

/**
 * Code that Changed the World
 * Pro said
 * Created by Pro on 2018-04-14.
 */
@Controller
@CommonsLog
public class LoginController {


    @GetMapping("/{status}/login")
    public String getLoginView(@PathVariable String status, Model model){
        log.debug("has user access:/"+status+"/login");
        model.addAttribute("loginUrl", status+"/login");
        return "/login.btl";
    }

    @PostMapping("/{status}/login")
    public String getLoginView(@PathVariable String status, String username, String password, Model model){
        log.debug("has user login failed; username is "+username);
        model.addAttribute("username", username);
        model.addAttribute("password", password);
        model.addAttribute("msg", "登录失败");
        model.addAttribute("loginUrl", status+"/login");
        return "/login.btl";
    }

}
